<template>
  <div class="">
    <!-- app-container -->
    <div class="head">
      <el-form :model="queryParams" ref="queryForm" :inline="true" :label-width="labelWidth">
        <el-form-item label="" prop="" >
          <el-input v-model="queryParams.keyword" placeholder="订单编号、活动名称、卡名称、姓名、手机" clearable style="width: 320px" />
        </el-form-item>
        <el-form-item label="发行方：" prop="">
          <el-select v-model="queryParams.issuerId" placeholder="请选择" filterable clearable :style="{width: inputWidth}">
            <el-option v-for="(item,index) in issuerList" :key="index" :label="item.value" :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="发行店铺：" prop="">
          <el-select v-model="queryParams.merchantId" placeholder="请选择" filterable clearable
            :style="{width: inputWidth}">
            <el-option v-for="dict in merchantList" :key="dict.id" :label="dict.value" :value="dict.id" />
          </el-select>
        </el-form-item>
        
        <el-form-item label="订单状态：" prop="">
          <el-select v-model="queryParams.status" placeholder="请选择" filterable clearable
            :style="{width: inputWidth}">
            <el-option v-for="dict in statusList" :key="dict.id" :label="dict.value" :value="dict.id" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="listBox">
      <div class="listBox_head">
        <export-excel-button title="活动订单" action="/shenye/asset/package/order/export" :params="ExportParams" />
      </div>
      <el-table v-loading="loading" :data="tabList" stripe border>
        <el-table-column label="序号" align="center" type="index" width="64px" />
        <el-table-column label="订单编号" align="center" prop="orderNo" />
        <el-table-column label="交易时间" align="center" prop="transactionTime" :show-overflow-tooltip="true" width="120px" />
        <el-table-column label="活动名称" align="center" prop="name" />
        <el-table-column label="卡名称" align="center" prop="cardName" />
        <el-table-column label="发行方" align="center" prop="issuerName" width="108" />
        <el-table-column label="发行店铺" align="center" prop="shopName" :show-overflow-tooltip="true" width="120px" />
        <el-table-column label="姓名" align="center" prop="customerName" :show-overflow-tooltip="true" width="120px" />
        <el-table-column label="手机号" align="center" prop="phone" />
        <el-table-column label="订单状态" align="center" prop="status"/>
        <el-table-column label="实付金额" align="center" prop="payMoney" />
        <el-table-column label="积分激励" align="center" prop="integralGiveAmount" />
        <el-table-column label="勋章激励" align="center" prop="medalIncentiveAmount" width="100" />
        <el-table-column label="勋章赠送" align="center" prop="medalCardName" />
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList" />
    </div>
  </div>
</template>

<script>
  import {
    orderList,
    shenyemerchant,
    issuerSelect,
  } from "@/api/assetPackage/activityList";
  import ExportExcelButton from "@/components/ExportExcelButton/index";
  
  export default {
    // dicts: ['equity_card_issue_type', 'equity_card_sell_status'],
    name: "",
    components: {
      ExportExcelButton,
     
    },
    data() {
      return {
        labelWidth: '100px',
        inputWidth: '200px',
        //日期
        date: [],
        // 遮罩层
        loading: false,
        // 导出遮罩层
        exportLoading: false,
        // 选中数组
        ids: [],
        // 非多个禁用
        multiple: true,
        // 总条数
        total: 0,
        // 表格数据
        tabList: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          keyword: '', //查询关键字
          issuerId: '', //发行方id
          merchantId: '', //商家id
          status:'',//订单状态（1待支付 2 已完成 3 已取消） shenye_asset_package_order_status
        },
        orderCouponStatus: [], //使用状态下拉
        activityOrderType: [], //订单类型下拉
        statusList: [],
        merchantList: [],
        issuerList: [],
      };
    },
    computed: {
      ExportParams() {
        const params = {
          ...this.queryParams,
        };
        return params;
      },
    },
    created() {
      this.getOrderCouponStatus()
      this.getshop()
      this.getissuer()
      this.getList();
    },
    methods: {
      //获取使用状态、支付状态字典
      getOrderCouponStatus() {
        var dictType = "shenye_asset_package_order_status";
        this.$getSelectList(dictType)
          .then((res) => {
            var arr = [{
              id: "",
              value: "全部",
            }, ];
            this.statusList = arr.concat(res.result[0].dictList);
          })
          .finally(() => {
          });
      },
      //获取店铺下拉
      getshop(){
        shenyemerchant().then(res => {
          this.merchantList = res.result
        })
      },
      //获取发行店铺
      getissuer(){
        issuerSelect().then(res => {
          this.issuerList = res.result
        })
      },
      /** 查询列表 */
      getList() {
        this.loading = true;
        orderList(this.queryParams).then(response => {
          this.tabList = response.result.records;

          
          this.tabList = this.tabList.map(item => {
            for (var key in item) {
              if (!item[key]) {
                item[key] = "-";
              }
            }
            return item
          })
          this.total = response.result.total;
          this.loading = false;
        });
      },
      // 表单重置
      resetQuery() {
        this.date = []
        this.queryParams = {
          pageNum: 1,
          pageSize: 10,
          keyword: '', //查询关键字
          issuerId: '', //发行方id
          merchantId: '', //商家id
          status:'',
        }
        // this.resetForm("form");
        this.getList();
        this.getActivityOrderCount()
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
    }
  };

</script>
<style scoped>
  .head {
    box-shadow: 0px 4px 12px 0px rgb(1 41 99 / 6%);
    background-color: #fff;
    border-radius: 8px;
    padding: 20px 20px 0;
  }

  .listBox {
    box-shadow: 0px 4px 12px 0px rgb(1 41 99 / 6%);
    background-color: #fff;
    border-radius: 8px;
    padding: 20px 20px;
    margin-top: 10px;
  }

  .listBox_head {
    width: 100%;
    padding-bottom: 20px;
  }
</style>
